package main

import "fmt"

type person struct {
	Name string
	Age  int
}

type msg struct {
	Num int
}

func (m *msg) print() {
	fmt.Println(m.Num)
}

func main() {
	p1 := person{"xiaobai", 6}
	fmt.Println(p1)
	p1.Name = "xiaohei"
	fmt.Println(p1)
	fmt.Println("/-----------------------/")
	m := new(msg)
	m.Num = 1
	defer m.print() // 2
	defer func(m msg) {
		// 值copy
		fmt.Println("函数传参:")
		m.print() //1
	}(*m)
	m.Num = 2
}
